<template>
    <section>
        <sy-baselist
                ref="employ"
                editVue="./business/Cost_Apply_Edit.vue"
                :filters="filters"
                listUrl="server/business/CostApply.ashx?cmd=GetList"
                deleteUrl="server/business/CostApply.ashx?cmd=Delete"
                @onLoadRow="onLoadRow"
                :fixWhere="fixWhere"
                :ApproveID="4"
                :hideAdd="hideAdd"
        >
            <el-table-column prop="FDate" align="center"  header-align="center" label="时间"  width="120" >
            </el-table-column>
            <el-table-column prop="TypeName"  align="center" header-align="center" label="报账类别"  width="120" >
            </el-table-column>
            <el-table-column prop="UserName" align="center"  header-align="center" label="报账人"  width="100" >
            </el-table-column>
            <el-table-column prop="FCost" align="center"  header-align="center" label="金额"  width="100" >
            </el-table-column>
            <el-table-column prop="FNote" align="center"  header-align="center" label="用款事由"  width="220" >
            </el-table-column>
            <el-table-column prop="StatusName" label="状态" width="180">
            </el-table-column>
        </sy-baselist>
    </section>
</template>

<script>
    import util from '../../common/util'
    export default {
        data(){
            return {
                dvApprove:false,
                fixWhere:'',
                filters:[],
                hideAdd:false
            }
        },
        methods:{
            onLoadRow(row)
            {
                row.FDate = util.date.format(row.FDate,'yyyy-MM-dd')
                switch(row.FApproveStatus)
                {
                    case 0: row.StatusName="未提交" ; break;
                    case 1: row.StatusName="待项目负责人审核" ; break;
                    case 2: row.StatusName="待审批" ; break;
                    case 3: row.StatusName="审批完成" ; break;
                    case -1: row.StatusName="负责人审核核退回" ; break;
                    case -2: row.StatusName="审批退回" ; break;
                    default: row.StatusName='未知'
                }
                if(row.FApproveStatus!=0&&row.FApproveStatus!=-1){
                    row.hideDeleteBtn=true;
                    row.hideEditBtn=true;
                    if((row.FToApprover!=global.user.FID)||row.FApproveStatus==3)
                    {
                        row.ApproveTitle="查看"
                    }
                    else
                    {
                        row.ApproveTitle= "审核"
                    }
                }
                if(row.FApproveStatus==0||row.FApproveStatus==-1) {
                    row.ApproveTitle= "提交审核"
                }
                if(row.FApproveStatus!=3)
                {
                    row.hidePrint=true;
                }
            },
            init(){
                if(global.nowPath=="/cost-0"){
                    this.fixWhere='FApproveStatus in (0,-1)'
                    this.hideAdd=true
                }else if(global.nowPath=="/cost-1"){
                    this.fixWhere='FApproveStatus in (1)'
                    this.hideAdd=true
                }else if(global.nowPath=="/cost-2"){
                    this.fixWhere='FApproveStatus in (3)'
                    this.hideAdd=true
                }else {
                    this.fixWhere=''
                    this.hideAdd=false
                }
                this.filters=[{type: "string",name:"UserName",text:"报账人", value: ""},
                    {type: "date",name:"FDate",text:"入职时间", value: null},
                    {type: "select",name:"FCostTypeID",text:"类别", data:"server/setting/CostType.ashx?cmd=GetOptions"}
                    ]
                if(this.fixWhere){

                }else{
                    this.filters.push(
                        {type: "select",name:"FApproveStatus",text:"状态", data:[[0,"未提交"],
                            [1,"待复核"],[2,"待审批"],[3,"审批完成"],[-1,"复核退回"],[-2,"审批退回"]],value:null})
                }
            }
        },
        watch: {
            '$route' (to, from) {
                // 对路由变化作出响应...
                this.init()
            }
        },
        created(){
            this.init()
       }
    }
</script>